package corej.course.collection.set.sortedset;

public class Student implements Comparable {
    String name;

    int age;

    public Student(String name, int age) {
        super();
        this.name = name;
        this.age = age;
    }

    public String toString() {
        return "Student " + name + "  " + age;
    }

    /*
      * public boolean equals(Object o){ System.out.println("Run Equals"); if
      * (this==o) return true; if (o==null) return false; if
      * (this.getClass()!=o.getClass()) return false; Student s=(Student)o; if
      * (this.name.equals(s.name) && this.age==s.age) return true; else return
      * false; } public int hashCode(){ return age+name.hashCode(); }
      */
    public int compareTo(Object o) {
        Student s = (Student) o;
        if (this.age != s.age)
            return this.age - s.age;
        else
            return this.name.compareTo(s.name);
    }

}
